<?php
// 基础控制器
namespace y\controllers;

use Yii;
use yii\web\Controller;

class BaseController extends Controller
{
	// 渲染页面
    public function fetch($data = [], $type = 1, $view = '')
    {
        switch ($type) {
            case 1: $renderFunc = 'render'; break;
            case 2: $renderFunc = 'renderPartial'; break;
            case 3: $renderFunc = 'renderAjax'; break;
            
            default: $renderFunc = 'render'; break;
        }
        empty($view) && $view = $this->action->id;
        return $this->$renderFunc($view, $data);
    }

    public function actionBox111()
    {
        $day = 24;
        $par = 33128;
        $js = 54469;
        $is = 1819;
        for ($i=$is; $i<=($is+34); $i++) {
            $id ='202205'.$day.'220523239A' . $i;
            if (in_array($i, [1504, 1517, 2407])) {
                $jss = $js + 31;
            }elseif ($i==2437) {
                $jss = $js + 29;
            }elseif ($i==2269) {
                $jss = $js + 17;
            }elseif ($i==2270) {
                $jss = $js + 24;
            } else {
                $jss = $js+30;
            }
            for ($j=$js; $j<$jss; $j++) {
                if (in_array($j, [72563, 71863, 72026, 71231])) {
                    $id3 ='202205'.$day.'220523239A2437';
                } elseif ($j==57602) {
                    $id3 ='202205'.$day.'220523239A1925';
                } else {
                    $id3 = $id;
                }
                if (in_array($j, [45047, 45070, 45416])) {
                    continue;
                }
                $id2 ='220523239A0' . $j;
                $sql = "INSERT INTO ebcproductioncode(Id,AddBy,AddTime,EditBy,EditTime,BatchCode,CodeLevel,CodePath,Count,FactoryId,IsRunning,LineId,MaterialId,MinSaleUnit,PackDate,ParentCode,PrintDate,RootCode,Sequence,ShouldOrgId,ShouldOrgType,ValidDate)
VALUES
('{$id2}','hpp','2022-06-11 08:00:00.000','hpp','2022-06-11 08:00:00.000','220523239A',1,'{$par},{$id3}',1,'9e0c70cc-a631-4408-8daf-529cbb629e95',0,1,'24ba45d9-c51e-44ec-83d2-89cf840c815e',1,'2021-05-{$day} 00:00:00.000','{$id3}','2022-05-{$day} 00:00:00.000','{$par}',1,'a55a3fb6-7a4a-4a03-88ed-79390c9fae3c',3,'2023-11-{$day} 00:00:00.000');";
//                echo $sql . PHP_EOL;
                Yii::$app->db_yisu2->createCommand($sql)->execute();
            }
            $js = $jss;
        }
        exit;
    }
}